#include "Token.h"
#include "Scanner.h"
#include "Information.h"

Token::Token(TokenType newType, size_t newLine, size_t newColumn, void* newInfo) :
		type(newType), line(newLine), column(newColumn), information(newInfo) {
}

Token::~Token() {
	// Storage class cleans up
}
void Token::setInformation(void* newInfo) {
	information = newInfo;
}
void Token::setType(TokenType newType) {
	type = newType;
}
void Token::setLine(size_t newLine) {
	line = newLine;
}
void Token::setColumn(size_t newColumn) {
	column = newColumn;
}

void* Token::getInformation() {
	return information;
}
TokenType Token::getType() {
	return type;
}
size_t Token::getLine() {
	return line;
}
size_t Token::getColumn() {
	return column;
}
char* Token::getLexem() {
	if (type == RESERVED_WORD || type == IDENTIFIER) {
		return ((SymInfo*) information)->lexem;
	}
	return ((InformationError*) information)->lexem;
}
int Token::getValue() {
	if (type == INTEGER) {
		return ((InformationInteger*) information)->number;
	}
	return 0;
}

void Token::cleanup() {
	// delete information;  // either cast or let someone else delete
}
